

########### Figure 1 #####################

data <- read.csv("UNHCR_Data_08052016.csv", sep=",", header=TRUE)

## Overall Difference ##

data1 <- data[data$hrc_member!=1,]
data2 <- data[data$hrc_member==1,]

other <- data1$latentmean
hr <- data2$latentmean

t.test(other,hr)

mean(other)-mean(hr)

## Difference Before & After ##

data1 <- data[data$hrc_member!=1,]
data1B <- data1[data1$year<=2005,]
data1A <- data1[data1$year>=2006,]


data2 <- data[data$hrc_member==1,]
data2B <- data2[data2$year<=2005,]
data2A <- data2[data2$year>=2006,]

# Difference Before 2006 Reform
mean(data1B$latentmean)-mean(data2B$latentmean)

# Difference After 2006 Reform
mean(data1A$latentmean)-mean(data2A$latentmean)

############### Figure 2 ##############################


### Africa ###
datax <- data[data$region=="Africa",]

data1 <- datax[datax$hrc_member!=1,]
data1B <- data1[data1$year<=2005,]
data1A <- data1[data1$year>=2006,]

data2 <- datax[datax$hrc_member==1,]
data2B <- data2[data2$year<=2005,]
data2A <- data2[data2$year>=2006,]

# Difference After 2006 Reform
mean(data1A$latentmean)-mean(data2A$latentmean)

### Asia-Pacific ###
datax <- data[data$region=="Asia-Pacific",]

data1 <- datax[datax$hrc_member!=1,]
data1B <- data1[data1$year<=2005,]
data1A <- data1[data1$year>=2006,]

data2 <- datax[datax$hrc_member==1,]
data2B <- data2[data2$year<=2005,]
data2A <- data2[data2$year>=2006,]

# Difference After 2006 Reform
mean(data1A$latentmean)-mean(data2A$latentmean)

### Eastern Europe ###
datax <- data[data$region=="Eastern Europe",]

data1 <- datax[datax$hrc_member!=1,]
data1B <- data1[data1$year<=2005,]
data1A <- data1[data1$year>=2006,]

data2 <- datax[datax$hrc_member==1,]
data2B <- data2[data2$year<=2005,]
data2A <- data2[data2$year>=2006,]

# Difference After 2006 Reform
mean(data1A$latentmean)-mean(data2A$latentmean)

### Latin America and Caribbean ###
datax <- data[data$region=="Latin America and Caribbean",]

data1 <- datax[datax$hrc_member!=1,]
data1B <- data1[data1$year<=2005,]
data1A <- data1[data1$year>=2006,]

data2 <- datax[datax$hrc_member==1,]
data2B <- data2[data2$year<=2005,]
data2A <- data2[data2$year>=2006,]

# Difference After 2006 Reform
mean(data1A$latentmean)-mean(data2A$latentmean)



### Western Europe & Others ###
datax <- data[data$region=="Western Europe and Others",]

data1 <- datax[datax$hrc_member!=1,]
data1B <- data1[data1$year<=2005,]
data1A <- data1[data1$year>=2006,]

data2 <- datax[datax$hrc_member==1,]
data2B <- data2[data2$year<=2005,]
data2A <- data2[data2$year>=2006,]

# Difference After 2006 Reform
mean(data1A$latentmean)-mean(data2A$latentmean)


